/*
 * Copyright (c) 2014 pkzd/1.0, 颜文泽(robin)
 * All rights reserved.
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *
 *     1 Redistributions of source code must retain the above copyright
 *       notice, this list of conditions and the following disclaimer.
 *     2 Redistributions in binary form must reproduce the above copyright
 *       notice, this list of conditions and the following disclaimer in the
 *       documentation and/or other materials provided with the distribution.
 *
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND ANY
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY
 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

#ifndef MC_ELF_H
#define MC_ELF_H

#define ELF_MAGIC	0x464C457FU

#define ET_NONE		0x0
#define ET_REL		0x1
#define ET_EXEC		0x2
#define ET_DYN		0x3
#define ET_CORE		0x4

#define EM_NONE		0x0
#define EM_M32		0x1
#define EM_SPARC 	0x2
#define EM_386		0x3
#define EM_68k		0x4
#define EM_88k		0x5
#define EM_860		0x7
#define EM_MIPS		0x8

#define EV_NONE		0x0
#define EV_CURRENT	0x1

#define SHN_UNDEF	0x0

struct elfhd{
	int 	e_magic;
	char	e_ident[12];
	short	e_type;
	short	e_machine;
	int	e_version;
	int	e_entry;	
	int	e_phoff; 
	int	e_shoff;
	int	e_flags;
	short	e_ehsiz;
	short	e_phentsiz; 
	short 	e_phnum; 
	short	e_shentsiz; 
	short 	e_shnum; 	
	short	e_shstrndx; 
};

struct elfphd{
	int	e_type;
	int	e_offset; 
	int	e_vaddr;
	int	e_paddr; 
	int	e_filesiz; 
	int	e_memsiz;
	int	e_flags;
	int	e_align;
};

struct shhd{
	unsigned int 	e_name;
	unsigned int	e_type;
	unsigned int	e_flags;
	unsigned int	e_addr;
	unsigned int	e_offset; 
	unsigned int	e_size;
	unsigned int	e_link;
	unsigned int	e_info;
	unsigned int	e_addralign;
	unsigned int	e_entsize;
};

#endif
